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

FEAT_ Zendesk #1794

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

FEAT_ Zendesk #1794

wants to merge 12 commits into from

Conversation

jwalsh-vori
Copy link
Contributor

Adds a new Zendesk block with initial support for launching the Zendesk Messaging Web Widget

Copy link

vercel bot commented Sep 14, 2024

@jwalsh-famkit is attempting to deploy a commit to the Typebot Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

coderabbitai bot commented Sep 14, 2024

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jwalsh-vori
Copy link
Contributor Author

@baptisteArno replacement PR for Zendesk

Copy link
Owner

@baptisteArno baptisteArno left a comment

Choose a reason for hiding this comment

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

Ok sorry about this but I think the Authenticate User action is useless, it should be directly embedded in the Open Web Widget action. It would definitely make more sense.


## Authenticate Messaging User

This action will generate a JWT token that can be passed as a variable to Open Web Widget you to authenticate a user in Zendesk. It requires the `User ID`, `Name` `Email`. Optionally, you can also set `Email Is Verified` if the email address has been verified. This is recommended to be set if appropriate.
Copy link
Owner

Choose a reason for hiding this comment

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

I found https://developer.zendesk.com/documentation/zendesk-web-widget-sdks/sdks/web/enabling_auth_visitors/#email-verification

Zendesk will only look for verified email addresses in a JWT. If the email_verified claim is not set to true, the email address in the JWT will be ignored, and it will not be included in the end user's profile in Agent Workspace.

So I guess the Email Is Verified field is useless here. We just need to tell the user to make sure the email was verified priori to providing it to Typebot. We could put that in a moreInfoTooltip for the email field

Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally thought the same, however, because open web widget is a client side action, that would lead to exposing the secrets used to create the JWT token on the client which would be highly insecure, no?

Email Verified is used in the JWT signing process. It's possible and valid to use verified and unverified emails when launching the web widget however as you may be dealing with new customers as well as existing, verified customers so we need to support verified and unverified emails. What verification does is that it tells the agent on the other end of the chat that the customer is known.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@baptisteArno what are your thoughts on this?

Copy link
Owner

Choose a reason for hiding this comment

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

I originally thought the same, however, because open web widget is a client side action, that would lead to exposing the secrets used to create the JWT token on the client which would be highly insecure, no?

You should be able for that action to define a server run function AND and a web function. The server function will first be executed.

It's possible and valid to use verified and unverified emails when launching the web widget

But Zendesk is saying that if we provide Email without the email_verified field set to true then it will completely ignore the Email. So my question is what is the point to provide the email_verified field on Typebot. Let's make it always true and document the fact that the creator of the bot verifies the user email before providing it to Zendesk block

Or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You should be able for that action to define a server run function AND and a web function. The server function will first be executed.

Oh, I see so, would the run block for openWebWidget look like this then? How do I pass the token from the server side auth function to the client openWebWidget function as it doesn't appear that variables are available to the client functions?

run: { server: async ({ credentials: { conversationsSecretKey, conversationsKeyId }, options: { userId, name, email, isEmailVerified, tokenVariableId }, variables, }) => { if (!email || email.length === 0 || !userId || userId.length === 0 || !name || name.length === 0 || conversationsSecretKey === undefined || conversationsKeyId === undefined || tokenVariableId === undefined ) return variables.set(tokenVariableId, sign({ scope: 'user', external_id: userId, name: name, email: email, email_verified: "true" }, conversationsSecretKey, { algorithm: "HS256", keyid: conversationsKeyId })); }, web: { parseFunction: ({ options }) => { return { args: { isAuthEnabled: options.isAuthEnabled ? options.isAuthEnabled?.toString() : "false", token: options.token ?? null, key: options.key ?? null }, content: parseOpenMessenger() } } }, },

Copy link
Owner

Choose a reason for hiding this comment

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

In fact parseFunction is executed on the server so you are right it should have access to variables, credentials etc... And you won't even have to declare a server run function. Let me push an update, will let you know once you can merge main into this branch 🙏

Copy link
Owner

Choose a reason for hiding this comment

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

Done: f613ce3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NICE!! Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, have removed the auth action, updated the openWebWidget action to generate the token. Looks good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and email_verified is set to true now

Copy link
Owner

@baptisteArno baptisteArno left a comment

Choose a reason for hiding this comment

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

Awesome, that's much better.

I think we can definitely simplify this even more! 😅

  1. Make userId, name and email optional
  2. Remove isAuthEnabled ( because auth is implicitely enabled as soon as userId is provided)

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.

3 participants