3.6.2 • Published 2 years ago

jovo-platform-twilioautopilot v3.6.2

Weekly downloads
109
License
Apache-2.0
Repository
-
Last release
2 years ago

Twilio Autopilot Platform Integration

To view this page on the Jovo website, visit https://v3.jovo.tech/marketplace/jovo-platform-twilioautopilot

Learn more about Twilio Autopilot specific features that can be used with the Jovo Framework.

Introduction

The Twilio Autopilot platform allows you to build, train, and deploy bots that work across web and mobile chat, SMS, WhatsApp, and your contact center.

The platform is not completely integrated into the Jovo ecosystem yet. While you can use the framework to provide the logic for your bot, the language model has to be created on the Autopilot Developer Platform.

After creating your Autopilot bot, you simply have to set each task to redirect to the endpoint your Jovo project is running on:

{
	"actions": [
		{
			"redirect": "https://webhookv3.jovo.cloud/63709788-169b-4d6d-981c-d6ef9700bfad"
		}
	]
}

Basics

All of the Autopilot specific objects and functions are accessed using the $autopilotBot object:

// @language=javascript

this.$autopilotBot

// @language=typescript

this.$autopilotBot!

The object will only be defined if the incoming request is from Autopilot. Because of that, you should first check wether it's defined or not before accessing it:

// @language=javascript

if (this.$autopilotBot) {

}

// @language=typescript

if (this.$autopilotBot) {

}

Some of Autopilot's features are integrated directly into the framework while others are not.

The integrated ones are Say, Listen, Show, and Play. While Show and Play are Autopilot specific, Say and Listen where integrated into the basic functionalities of the framework, i.e. this.tell() and this.ask().

tell() is the same as Say and ask is the same as the combination of the Say and Listen actions.

Besides that, the $autopilotBot object provides the setActions() function, which allows you to set the array of actions yourself.

That way you can use any of the functionality provides by the Autopilot platform:

// @language=javascript

this.$autopilotBot.setActions([
  {
    say: 'Hi there! I\'m Jaimie your new Assistant. How can I help you'
  },
  {
    play: {
      loop: 2,
      url: 'https://api.twilio.com/cowbell.mp3'
    }
  },
  {
    redirect: 'task://customer-satisfaction-survey'
  }
]);

// @language=typescript

this.$autopilotBot!.setActions([
  {
    say: 'Hi there! I\'m Jaimie your new Assistant. How can I help you'
  },
  {
    play: {
      loop: 2,
      url: 'https://api.twilio.com/cowbell.mp3'
    }
  },
  {
    redirect: 'task://customer-satisfaction-survey'
  }
]);

Audioplayer - Play action

To play audio files in your response, you use the $audioPlayer object and its play() function.

// @language=javascript

this.$autopilotBot.$audioPlayer.play(
  'https://www.url.to/file.mp3'
  1
);

// @language=typescript

this.$autopilotBot!.$audioPlayer!.play(
  'https://www.url.to/file.mp3'
  1
);

The play() function has the following parameters:

NameDescriptionValueRequired
urlThe url to the hosted mp3 filestringyes
loopThe number of times the file should be loopednumberyes

Visual Output - Show action

To add a card to your response use the showStandardCard() function:

// @language=javascript

// without image
this.$autopilotBot.showStandardCard('Hello World');

// with image
this.$autopilotBot.showStandardCard(
  'Hello World',
  {
    label: 'Hello World Image',
    url: 'https://www.url.to/hello-world.png'
  }
);

// with multiple images
this.$autopilotBot.showStandardCard(
  'Hello World',
  [
    {
      label: 'Hello Image',
      url: 'https://www.url.to/hello.png'
    },
    {
      label: 'World Image',
      url: 'https://www.url.to/world.png'
    }
  ]
);

// @language=typescript

// without image
this.$autopilotBot!.showStandardCard('Hello World');

// with image
this.$autopilotBot!.showStandardCard(
  'Hello World',
  {
    label: 'Hello World Image',
    url: 'https://www.url.to/hello-world.png'
  }
);

// with multiple images
this.$autopilotBot!.showStandardCard(
  'Hello World',
  [
    {
      label: 'Hello Image',
      url: 'https://www.url.to/hello.png'
    },
    {
      label: 'World Image',
      url: 'https://www.url.to/world.png'
    }
  ]
);

The showStandardCard() function has the following parameters:

NameDescriptionValueRequired
contentThe body of the cardstringyes
imageEither an image or an array of imagesimageimage[]no
image.labelTag of the imagestringno
image.urlThe url to the hosted jpg or png filestringyes

New Session

Incoming requests from Twilio Autopilot don't specify wether the request is from a new session or an existing one. Parts of the Jovo functionality depends on that information, e.g. the NEW_SESSION intent.

If you want to use these features, you have to save the session ID in the database. You can do it by adding the following configuration to your project:

// @language=javascript

// src/config.js

module.exports = {
    
    user: {
        sessionData: {
            enabled: true,
            id: true
        },
    },

    // ...
};

// @language=typescript

// src/config.ts

const config = {
    
    user: {
        sessionData: {
            enabled: true,
            id: true
        },
    },

    // ...
};

After that, entries in your database will have the following schema:

{
    "userId": "...",
    "userData": {
        "data": {...}
        "session": {
            "lastUpdatedAt": "ISO 8601 string",
            "id": "session ID"
        }
    }
}
3.6.2

2 years ago

3.6.1

2 years ago

3.6.0

2 years ago

3.5.3

3 years ago

3.5.2

3 years ago

3.5.1

3 years ago

3.5.0

3 years ago

3.4.1

3 years ago

3.4.0

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.2.3

3 years ago

3.2.2

3 years ago

3.2.1

3 years ago

3.2.0

4 years ago

3.1.5

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.0

4 years ago

3.0.24

4 years ago

3.0.23

4 years ago

3.0.22

4 years ago

3.0.21

4 years ago

3.0.20

4 years ago

3.0.19

4 years ago

3.0.18

4 years ago

3.0.17

4 years ago

3.0.16

4 years ago

3.0.14

4 years ago

3.0.15

4 years ago

3.0.13

4 years ago

3.0.12

4 years ago

3.0.10

4 years ago

3.0.11

4 years ago

3.0.9

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.4

4 years ago

3.0.5

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.2.1-alpha.0

4 years ago