Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

An SDK to Integrate DialogFlow With Golang for Bot Development

DZone's Guide to

An SDK to Integrate DialogFlow With Golang for Bot Development

DialogFlow, a natural language processing service, offers many SDKs in different programming languages — but not Golang. Until now...

· AI Zone ·
Free Resource

Easily enforce open source policies in real time and reduce MTTRs from six weeks to six seconds with the Sonatype Nexus Platform. See for yourself - Free Vulnerability Scanner. 

DialogFlow (formerly API.AI) gives users new ways to interact with your bot by building engaging voice- and text-based conversational interfaces powered by AI.

DialogFlow offers many SDKs in different programming languages:

But unfortunately, there’s no SDK for Golang.

But don't be sad! I made an SDK to integrate DialogFlow with Golang:

This library allows integrating agents from the DialogFlow natural language processing service with your Golang application.

Issue the following command to install the library:

go get github.com/mlabouardy/dialogflow-go-client

The example below, display list of entities:

package main

import (
    "fmt"
    "github.com/mlabouardy/dialogflow-go-client"
    "github.com/mlabouardy/dialogflow-go-client/models"
    "log"
)

func main() {
    err, client: = NewDialogFlowClient(Options {
        AccessToken: "<DIALOGFLOW TOKEN GOES HERE>",
    })
    if err != nil {
        log.Fatal(err)
    }

    entities, err: = client.EntitiesFindAllRequest()
    if err != nil {
        log.Fatal(err)
    }
    for _, entity: = range entities {
        fmt.Println(entity.Name)
    }
}

Note: For more details about the available methods, check the project's GitHub repository.

For a real-world example on how to use this library, check my previous tutorial on how to create a Messenger Bot in Golang to show a list of movies playing in cinema, and TV shows airing on TV:

That's it! Comment below with any questions or observations.

Automate open source governance at scale across the entire software supply chain with the Nexus Platform. Learn more.

Topics:
ai ,chatbots ,nlp ,golang ,sdk ,bot development ,conversational interfaces

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}