Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Twilio-WhatsApp adapter #63

Merged
merged 10 commits into from
Aug 4, 2019

Conversation

iMicknl
Copy link
Contributor

@iMicknl iMicknl commented Jul 25, 2019

Adapter is working fine with Twilio Sandbox.

Notes for reviewer:

  • How should we do error handling in all adapters? I am trying to find the balance between throwing an error and just a console.warn, to prevent breaking bot flows.
  • Should we change text formatting from <b>text</b> tot *text* for example. Or should this transformation be done in the bot code / middleware. Currently those default HTML to supported markdown transformations are built in.
  • Not super Type strict since Twilio doesn't offer great typing for their package / API... More interfaces could be created in this package in the future.

TODO

  • Add unit tests
  • Check if oAuth support via Azure Bot Service is possible. [low-prio]

@iMicknl iMicknl marked this pull request as ready for review July 28, 2019 21:50
@iMicknl iMicknl requested a review from szul as a code owner July 28, 2019 21:50
@iMicknl
Copy link
Contributor Author

iMicknl commented Jul 28, 2019

@szul please do not merge yet. I accidentally changed it to 'Ready for Review'.

I just updated my example and the library to the latest version of botbuilder and it looks like there was a breaking change in the definitions. (Or my example wasn't set up right. I need to dig in a bit more).

Argument of type '(context: TurnContext) => Promise<void>' is not assignable to parameter of type '(context: TurnContext) => Promise<any>'.
  Types of parameters 'context' and 'context' are incompatible.
  Types have separate declarations of a private property '_adapter'.

szul and others added 2 commits July 30, 2019 07:44
commit 5f6bc7c
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Aug 1 00:04:11 2019 +0200

    add eslint disable

commit dc9cb5c
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Aug 1 00:02:25 2019 +0200

    Don’t escape unnecessary characters

commit 1802dfc
Merge: e055935 ac17d86
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Wed Jul 31 22:04:37 2019 +0200

    Merge branch 'master' into adapter/twilio-whatsapp

commit e055935
Merge: 694bba6 571cca7
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Mon Jul 29 01:54:06 2019 +0200

    Merge branch 'master' of github.com:BotBuilderCommunity/botbuilder-community-js into adapter/twilio-whatsapp

commit 694bba6
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Mon Jul 29 00:52:06 2019 +0200

    Revert "Change to const instead of let"

    This reverts commit ca9d8fb.

commit ca9d8fb
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Mon Jul 29 00:51:34 2019 +0200

    Change to const instead of let

commit 597624d
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Mon Jul 29 00:46:23 2019 +0200

    ESLint fixes

commit 0bfe9d9
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Mon Jul 29 00:38:03 2019 +0200

    ESLint fixes

commit 088acfa
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Mon Jul 29 00:12:47 2019 +0200

    Add changelog and info to root readme

commit 9443e63
Merge: 62f8bfc 1a5f093
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Mon Jul 29 00:03:50 2019 +0200

    Merge branch 'master' of github.com:BotBuilderCommunity/botbuilder-community-js into adapter/twilio-whatsapp

commit 62f8bfc
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 23:50:15 2019 +0200

    Add example

commit 0bdbead
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 23:25:17 2019 +0200

    Code cleanup for review

commit ae36618
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 23:17:59 2019 +0200

    Refactor event handling (2)

commit 99ef3d4
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 23:03:12 2019 +0200

    Refactor event handling

commit bc128b8
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 22:45:47 2019 +0200

    Remove need for bodyParser()

commit 7013575
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 22:44:44 2019 +0200

    Implement bodyParser for www-form-urlencoded

commit a6fb046
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 22:24:52 2019 +0200

    Add support for Express + Restify without bodyParser()

commit 28b85f4
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 22:03:18 2019 +0200

    Add adapter with filename using camelCasing

commit 6f36f80
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 22:02:40 2019 +0200

    Remove adapter

commit e012e26
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 20:03:41 2019 +0200

    Update Readme

commit c59c824
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Jul 25 15:24:56 2019 +0200

    Add formatting changes and clean up current code

commit 31eaa3c
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Jul 25 14:41:25 2019 +0200

    Fixes

commit 2310822
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Jul 25 13:26:06 2019 +0200

    Add beta status

commit a001e28
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Jul 25 13:19:20 2019 +0200

    Improve documentation

commit f86470f
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Jul 25 12:46:47 2019 +0200

    Better error handling

commit 5a149d5
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Jul 25 12:25:56 2019 +0200

    Update documentation and add constant for channelId

commit 198628b
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Jul 25 12:07:20 2019 +0200

    Improve documentation

commit f7ed61e
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Jul 25 11:55:40 2019 +0200

    Add codeowners reference

commit c708ec9
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Jul 25 11:53:15 2019 +0200

    Update package-lock

commit 3eb2bc3
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Jul 25 11:50:07 2019 +0200

    Initial commit
@iMicknl
Copy link
Contributor Author

iMicknl commented Jul 31, 2019

@szul It is ready for review. Could you have a look? I just need to write some unit tests before merge.

The issue of my previous post is resolved, thanks to @stevengum. Apparently my test project had different versions of botbuilder dependencies.

@szul
Copy link
Contributor

szul commented Aug 1, 2019

@iMicknl That happened to me before: test directory node modules were out-of-sync with the base of the package ☹️

Copy link
Contributor

@szul szul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When initially running the tests for this, I received the following error:

C:\Users\micha\x\botbuilder-community-js\libraries\botbuilder-adapter-twilio-whatsapp\lib\twilioWhatsAppAdapter.js:258
            activity.text = activity.text.replace(/<b>(.*?)<\/b>/gis, '*$1*');
                                                  ^

SyntaxError: Invalid regular expression flags

The syntax looked correct to me, and the flags were valid with the latest online documentation, so I checked my Node.JS version, which was in 8.x.x range. I upgraded to the latest Node.JS, and the tests then started running. Not sure if we need to make a note about Node.JS version support.

This is good to go. I left some minor version and language comments I think we should debate/change before merging.

CODEOWNERS Outdated Show resolved Hide resolved
libraries/botbuilder-adapter-twilio-whatsapp/package.json Outdated Show resolved Hide resolved
@iMicknl
Copy link
Contributor Author

iMicknl commented Aug 4, 2019

@szul good catch! I didn't know the s expression flag is supported since > Node 8.. I am not sure which Node version we need to support? (and I think we should clearly state it somewhere in the documentation).

@szul szul mentioned this pull request Aug 4, 2019
@szul szul merged commit 431585e into BotBuilderCommunity:master Aug 4, 2019
iMicknl added a commit to iMicknl/botbuilder-community-js that referenced this pull request Aug 5, 2019
commit eb9055b
Merge: 39fcc06 90f933d
Author: Michael Szul <michael@szul.us>
Date:   Sun Aug 4 09:46:51 2019 -0400

    Merge pull request BotBuilderCommunity#81 from iMicknl/adapter/twilio-whatsapp

    Fix README

commit 90f933d
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Aug 4 15:44:53 2019 +0200

    Add botbuilder prefix

commit 39fcc06
Merge: 431585e d29449b
Author: Michael Szul <michael@szul.us>
Date:   Sun Aug 4 09:44:36 2019 -0400

    Merge pull request BotBuilderCommunity#80 from iMicknl/adapter/twilio-whatsapp

    Fix link in README

commit d29449b
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Aug 4 15:41:39 2019 +0200

    Readme fix

commit 431585e
Merge: ac17d86 f68bc16
Author: Michael Szul <michael@szul.us>
Date:   Sun Aug 4 09:37:31 2019 -0400

    Merge pull request BotBuilderCommunity#63 from iMicknl/adapter/twilio-whatsapp

    Add Twilio-WhatsApp adapter

commit f68bc16
Merge: 26607d7 c26f07e
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Aug 4 15:12:23 2019 +0200

    Merge branch 'adapter/twilio-whatsapp' of github.com:iMicknl/botbuilder-community-js into adapter/twilio-whatsapp

commit 26607d7
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Aug 4 15:11:14 2019 +0200

    Improve documentation

commit c26f07e
Merge: ebe5581 9bc47a4
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Aug 4 15:05:26 2019 +0200

    Merge pull request #1 from szul/twilio

    Minor tweaks

commit 9bc47a4
Author: Michael Szul <michael@szul.us>
Date:   Sun Aug 4 08:38:22 2019 -0400

    Updated version to basic 0.1.0 release and alphabetized codeowners

commit 280741e
Merge: b2296fd ebe5581
Author: Michael Szul <michael@szul.us>
Date:   Thu Aug 1 10:42:36 2019 -0400

    Merge pull request BotBuilderCommunity#17 from iMicknl/adapter/twilio-whatsapp

    Adapter/twilio whatsapp

commit ebe5581
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Aug 1 09:58:39 2019 +0200

    Abstract creation of Twilio client

commit 8ed5356
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Aug 1 00:43:52 2019 +0200

    Add first unit tests

commit c0aa8f2
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Aug 1 00:43:45 2019 +0200

    Add missing SmsStatus

commit 9a97285
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Thu Aug 1 00:06:40 2019 +0200

    First version of TwilioWhatsAppAdapter

    commit 5f6bc7c
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Aug 1 00:04:11 2019 +0200

        add eslint disable

    commit dc9cb5c
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Aug 1 00:02:25 2019 +0200

        Don’t escape unnecessary characters

    commit 1802dfc
    Merge: e055935 ac17d86
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Wed Jul 31 22:04:37 2019 +0200

        Merge branch 'master' into adapter/twilio-whatsapp

    commit e055935
    Merge: 694bba6 571cca7
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Mon Jul 29 01:54:06 2019 +0200

        Merge branch 'master' of github.com:BotBuilderCommunity/botbuilder-community-js into adapter/twilio-whatsapp

    commit 694bba6
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Mon Jul 29 00:52:06 2019 +0200

        Revert "Change to const instead of let"

        This reverts commit ca9d8fb.

    commit ca9d8fb
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Mon Jul 29 00:51:34 2019 +0200

        Change to const instead of let

    commit 597624d
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Mon Jul 29 00:46:23 2019 +0200

        ESLint fixes

    commit 0bfe9d9
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Mon Jul 29 00:38:03 2019 +0200

        ESLint fixes

    commit 088acfa
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Mon Jul 29 00:12:47 2019 +0200

        Add changelog and info to root readme

    commit 9443e63
    Merge: 62f8bfc 1a5f093
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Mon Jul 29 00:03:50 2019 +0200

        Merge branch 'master' of github.com:BotBuilderCommunity/botbuilder-community-js into adapter/twilio-whatsapp

    commit 62f8bfc
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Sun Jul 28 23:50:15 2019 +0200

        Add example

    commit 0bdbead
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Sun Jul 28 23:25:17 2019 +0200

        Code cleanup for review

    commit ae36618
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Sun Jul 28 23:17:59 2019 +0200

        Refactor event handling (2)

    commit 99ef3d4
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Sun Jul 28 23:03:12 2019 +0200

        Refactor event handling

    commit bc128b8
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Sun Jul 28 22:45:47 2019 +0200

        Remove need for bodyParser()

    commit 7013575
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Sun Jul 28 22:44:44 2019 +0200

        Implement bodyParser for www-form-urlencoded

    commit a6fb046
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Sun Jul 28 22:24:52 2019 +0200

        Add support for Express + Restify without bodyParser()

    commit 28b85f4
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Sun Jul 28 22:03:18 2019 +0200

        Add adapter with filename using camelCasing

    commit 6f36f80
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Sun Jul 28 22:02:40 2019 +0200

        Remove adapter

    commit e012e26
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Sun Jul 28 20:03:41 2019 +0200

        Update Readme

    commit c59c824
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Jul 25 15:24:56 2019 +0200

        Add formatting changes and clean up current code

    commit 31eaa3c
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Jul 25 14:41:25 2019 +0200

        Fixes

    commit 2310822
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Jul 25 13:26:06 2019 +0200

        Add beta status

    commit a001e28
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Jul 25 13:19:20 2019 +0200

        Improve documentation

    commit f86470f
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Jul 25 12:46:47 2019 +0200

        Better error handling

    commit 5a149d5
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Jul 25 12:25:56 2019 +0200

        Update documentation and add constant for channelId

    commit 198628b
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Jul 25 12:07:20 2019 +0200

        Improve documentation

    commit f7ed61e
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Jul 25 11:55:40 2019 +0200

        Add codeowners reference

    commit c708ec9
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Jul 25 11:53:15 2019 +0200

        Update package-lock

    commit 3eb2bc3
    Author: Mick Vleeshouwer <mick@imick.nl>
    Date:   Thu Jul 25 11:50:07 2019 +0200

        Initial commit

commit b2296fd
Merge: 5859b9f ac17d86
Author: Michael Szul <michael@szul.us>
Date:   Tue Jul 30 07:44:59 2019 -0400

    Merge pull request BotBuilderCommunity#16 from BotBuilderCommunity/master

    Merge back (CODEOWNERS)

commit ac17d86
Merge: 571cca7 e951b6d
Author: Michael Szul <michael@szul.us>
Date:   Tue Jul 30 07:44:14 2019 -0400

    Merge pull request BotBuilderCommunity#72 from szul/codeowners

    Update CODEOWNERS to correct errors

commit e951b6d
Author: Michael Szul <michael@szul.us>
Date:   Tue Jul 30 07:42:42 2019 -0400

    Update CODEOWNERS to correct errors

commit 5859b9f
Merge: c3fcb10 571cca7
Author: Michael Szul <michael@szul.us>
Date:   Mon Jul 29 15:19:58 2019 -0400

    Merge pull request BotBuilderCommunity#15 from BotBuilderCommunity/master

    Merge back

commit 571cca7
Merge: 1a5f093 27263ec
Author: Michael Szul <michael@szul.us>
Date:   Sun Jul 28 19:24:05 2019 -0400

    Merge pull request BotBuilderCommunity#69 from iMicknl/eslint

    Add ESLint to root

commit 27263ec
Merge: 25bd549 1a5f093
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Mon Jul 29 01:06:48 2019 +0200

    Merge branch 'master' of github.com:BotBuilderCommunity/botbuilder-community-js into eslint

    # Conflicts:
    #	package-lock.json

commit 25bd549
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Mon Jul 29 01:05:40 2019 +0200

    Fix `botbuilder-text-recognizer-middleware`

commit 3380fec
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Mon Jul 29 00:59:30 2019 +0200

    Add basic ESLint setup

commit 1a5f093
Merge: d7c484e b0ffc18
Author: Michael Szul <michael@szul.us>
Date:   Sun Jul 28 17:14:43 2019 -0400

    Merge pull request BotBuilderCommunity#67 from iMicknl/readme_updates

    Updates to root README.md

commit b0ffc18
Merge: b5caf27 d7c484e
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 20:52:27 2019 +0200

    Merge branch 'master' of github.com:BotBuilderCommunity/botbuilder-community-js into readme_updates

    # Conflicts:
    #	README.md

commit b5caf27
Author: Mick Vleeshouwer <mick@imick.nl>
Date:   Sun Jul 28 20:51:15 2019 +0200

    Update readme

commit d7c484e
Merge: a580708 c3fcb10
Author: Michael Szul <michael@szul.us>
Date:   Fri Jul 26 12:47:20 2019 -0400

    Merge pull request BotBuilderCommunity#66 from szul/master

    Update to SDK 4.5.3

commit c3fcb10
Author: Michael Szul <michael@szul.us>
Date:   Fri Jul 26 12:46:04 2019 -0400

    Update to SDK 4.5.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants