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

fix(webchat): convert plain URLs to links in markdown messages #607

Merged
merged 3 commits into from
Jul 6, 2023

Conversation

AbrahamLopez10
Copy link
Member

No description provided.

@AbrahamLopez10 AbrahamLopez10 requested a review from a team as a code owner July 5, 2023 19:04
@linear
Copy link

linear bot commented Jul 5, 2023

CLS-951 [webchat] Hyperlinks not working in webchat

Hyperlinks are working in the emulator, but not in the webchat deployed on my personal website (see screenshots below)

These are both text cards :-)

same chatbot, haven't made changes since publishing + deploying

Screenshot 2023-06-12 at 10.39.23 AM.png

Screenshot 2023-06-12 at 10.39.53 AM.png

@@ -7,7 +7,7 @@ config.set_enabled_resources([

webchat_port = 3543
inject_port = 8080
messaging_port = 3100
messaging_port = 3101
Copy link
Member Author

Choose a reason for hiding this comment

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

note: This is so messaging in this Tilt setup doesn't clash with messaging in Skynet by default, so it's easier to have this running alongside Skynet.

@@ -37,7 +37,11 @@ local_resource(
local_resource(
name="webchat",
serve_dir="packages/inject",
serve_cmd="yarn serve",
cmd="mkdir -p dist && yarn copy:shareable",
Copy link
Member Author

Choose a reason for hiding this comment

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

note: This fixes the webchat UI not being styled locally when serving from Tilt.

@@ -1,13 +1,15 @@
import { createIntl } from 'react-intl'
import snarkdown from 'snarkdown'
Copy link
Member Author

Choose a reason for hiding this comment

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

note: snarkdown is quite outdated, so we're replacing it with MarkdownIt which supports converting plain URLs to links.

if (escaped) {
message = message.replace(/</g, '&lt;').replace(/>/g, '&gt;')
}

const html = snarkdown(message)
const md = new MarkdownIt({ linkify: true })
Copy link
Member Author

@AbrahamLopez10 AbrahamLopez10 Jul 5, 2023

Choose a reason for hiding this comment

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

note: The bug was that the webchat integration sends text messages with markdown: true always (by design, so that people can freely use markdown in the Studio), so to fix the issue we need to convert plain URLs in markdown to actual links.

@AbrahamLopez10 AbrahamLopez10 merged commit d341cf8 into master Jul 6, 2023
19 checks passed
@AbrahamLopez10 AbrahamLopez10 deleted the CLS-951-fix-webchat-links branch July 6, 2023 14:37
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