Skip to content

Instantly share code, notes, and snippets.

@MithunArunan
Last active January 12, 2023 00:37
Show Gist options
  • Save MithunArunan/a6da20582c2b24810f0e3bf02c5bfa10 to your computer and use it in GitHub Desktop.
Save MithunArunan/a6da20582c2b24810f0e3bf02c5bfa10 to your computer and use it in GitHub Desktop.

DialogFlow

Create a Dialogflow account and Dialogflow agent

Google OAuth

Intents & Extract parameters with entities

Training Phrases

Each training phrase can have more than one entity (@sys or custom), should be manually tagged on double click. Format,

"I want to talk in english"

- Parameter name: language
- Entity: @sys.language
- Resolved Value: english

Training phrases will be provided as ontology to ASR.

Action and Parameters

Parameters are specific values extracted from a user's request when entities are matched. The values captured by parameters can be used in fulfillment, or in building a response. If you mark parameters as required, Dialogflow will prompt the user if their values were not extracted from their initial request.

- Required: 
- Parameter name: language
- Entity: @sys.language
- Value: $english
- isList: 
- Prompts: (if required set to True)

Responses

Execute and respond to the user

Channel Wise

  • DEFAULT
  • Google Assistant

Fulfillment

Call a web service to connect your back-end. Validate the data or give better responses.

  • Enable webhook call for this intent.
  • Enable webhook call for slot filling.

Contexts

Events

Trigger the intent from non-verbal signals

Manage states with contexts, which lets you persist conversation state across turns of a conversation

Fulfillment with the Actions or Dialogflow webhook

To process user input based on client logic and return better responses

History | Conversations

Analytics

Pre-Built Agents

Integrations

Example conversation - Agent

USER: `i want to talk in english`

BOT: `Ok. Now, tell me your query?`

INTENT: `Language Selection`

ACTION: `Not available`

PARAMETER	NAME: `language`

VALUE: `English`
{
  "id": "91cf5ccd-4baf-4d72-b98a-1107fc1241ef",
  "name": "Language Selection",
  "auto": true,
  "contexts": [],
  "responses": [
    {
      "resetContexts": false,
      "action": "",
      "affectedContexts": [],
      "parameters": [
        {
          "id": "03541ce7-89e5-454d-8648-2f02053aff58",
          "required": true,
          "dataType": "@sys.language",
          "name": "language",
          "value": "$language",
          "prompts": [
            "Please let me know your language of choice?",
            "English or Hindi? What would you prefer?"
          ],
          "isList": false
        }
      ],
      "messages": [
        {
          "type": 0,
          "speech": "Ok. Now, tell me your query?"
        }
      ],
      "defaultResponsePlatforms": {},
      "speech": []
    }
  ],
  "priority": 500000,
  "cortanaCommand": {
    "navigateOrService": "NAVIGATE",
    "target": ""
  },
  "webhookUsed": true,
  "webhookForSlotFilling": true,
  "lastUpdate": 1533705859,
  "fallbackIntent": false,
  "events": [],
  "userSays": [
    {
      "id": "159c48bb-d9ab-4a73-88e5-7d05c05a2f4e",
      "data": [
        {
          "text": "can we use "
        },
        {
          "text": "english",
          "alias": "language",
          "meta": "@sys.language",
          "userDefined": true
        },
        {
          "text": " instead"
        }
      ],
      "isTemplate": false,
      "count": 0,
      "updated": 1533705859,
      "isAuto": false
    },
    {
      "id": "c983556a-6e8e-48fb-b9be-e8e003250171",
      "data": [
        {
          "text": "I want to talk in "
        },
        {
          "text": "tamil",
          "alias": "language",
          "meta": "@sys.language",
          "userDefined": true
        }
      ],
      "isTemplate": false,
      "count": 0,
      "updated": 1533705859,
      "isAuto": false
    },
    {
      "id": "14c6cc61-de44-414e-984e-4084721b36dc",
      "data": [
        {
          "text": "I want to talk in "
        },
        {
          "text": "hindi",
          "alias": "language",
          "meta": "@sys.language",
          "userDefined": true
        }
      ],
      "isTemplate": false,
      "count": 0,
      "updated": 1533705859,
      "isAuto": false
    },
    {
      "id": "0dc23f6a-9462-46db-8550-8bd02c64ce88",
      "data": [
        {
          "text": "I "
        },
        {
          "text": "want",
          "meta": "@sys.ignore",
          "userDefined": true
        },
        {
          "text": " to talk in "
        },
        {
          "text": "english",
          "alias": "language",
          "meta": "@sys.language",
          "userDefined": false
        }
      ],
      "isTemplate": false,
      "count": 0,
      "updated": 1533705859,
      "isAuto": false
    }
  ],
  "followUpIntents": [],
  "liveAgentHandoff": false,
  "endInteraction": false,
  "templates": []
}

References

DialogFlow - Getting started

Requirements

  • Add a new telephony provider.

  • Add a new client.

  • Associate an existing provider for the client.

  • Associate global configuration for the client.

  • Associate a default call flow for the client.

  • Associate a virtual number to the client and map it to a flow.

  • Conversational view of the calls.

  • Analytics on no. of calls.

  • Modular, detailed, reusable call flow with publish feature.

Cloud Telephony Architecture

GLOSSARY

PSTN - Public switched telephone network

PBX - Private branch exchange

VOIP - Voice over IP

Network providers for virtual numbers

PRI - Primary rate interface (PRI lines to be provided by telecoms)

CTI - Computer telephony integration - Dialogic/Donjin/KeyGoe card

IVR software - Asterisk, FreeSwitch, FreePBX

GSM Gateway

  • 4/8 ports

  • Telephone interface - FXO, RJ11

  • LAN interface - 2x RJ45 10/100Mbp

  • DTMF detection - RFC2833 (RTP)

  • Audio codecs

IP-PBX with Asterisk & FreePBX

  • 4U PBX 19” rack. Linux server with Asterisk installed

  • LAN interface - 2x RJ45 10/100Mbp

  • Protocols - MGCP, SCCP

  • FastAGI (Asterisk Gateway interface)

  • AMI (Asterisk Manager interface)

  • ARI (Asterisk Rest interface)

  • ari.asterisk.org

Functionality requirements

  1. Streaming audio payloads. To reduce latency.

  2. End record and play another audio back to the user.

  3. Voice and DTMF inputs at the same time

  4. Silence detection

  5. Call meta details

  6. Dynamic dial plan configuration

On-premise setup

  1. Data center space
  2. PRI cards
  3. Software and their licenses
  4. Govt licence
  5. Connectivity with the operator.

InBound/OutBound/Blend

PRI line (postpaid) 11,800 or GSM (4 calls at the same time) HP proliant ML 10 8GB RAM 1TB

References

GSM Gateway

Bronchure

Astecs

IP PBX with Asterisk

https://www.asttecs.com/pdf/Education-Institutions-IP-PBX-Brochure.pdf

Mark Spencer Founder Asterisk and Digium - https://www.youtube.com/watch?v=ZvOAim-zWTo

https://www.voip-info.org/how-to-connect-voip-gsm-gateway-to-asterisk-pbx/

http://www.asteriskdocs.org/ http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html/asterisk-book.html

Docker image: https://github.com/dougbtv/docker-asterisk

https://github.com/asterisk/ari-examples

Twilio

Twilio - Programmable Voice

Twilio Studio - User guide

Twilio - Training - Voice

Numbers or Virtual Numbers

Add new number View and manager numbers - Phone number, Capabilities

Twilio Studio

Studio Features

Trigger Flows via Inbound SMS, Inbound Voice Calls, and Webhooks

Create, Modify, and Destroy Flows (Workflows) with revisions. (New flow changes will not impact the current live calls)

Add and Remove Transitions

Manage Widget Settings with the Inspector Panel

Define Transitions to Advance Users through Flows

Create and Pass Variables - Flow context

View Engagements (Individual runs through flows)

Organize Use Cases and Logic in Separate Flows

UI/UX

  • Create a new flow or create from Templates (Start from scratch, SMS chatbot, IVR/Phone tree, SMS survey)
  • Drag & drop triggers and widgets (pre-definded logic). Wire it with the right transitions.
  • Save Flow with revision history and publish when required.
  • Link flows to virtual numbers.
  • Look at flow logs to debug and examine customer engagement with the flow.
TODO: Look at api level details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment