It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Insert text in the chat input

Hello. I trying to do this. But i need it in firefox extension. I'm including:
bitbucket.org/atlassian/simple-xdm/raw/62355f436bb3966cf4098f41cef544b7dbc4c6bc/dist/iframe.min.js

ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js

aui-cdn.atlassian.com/aui-adg/5.8.14/js/aui.js

and do this:

require('chat', function(chat) {
chat.appendMessage('Hello');
});

So, iframe.min.js say me this:

Error: See almond README: incorrect module build, no module name.

Could anyone give me full code (outside the HipChat ext) or say what i missed? Thanks.

4 answers

0 votes
rich Atlassian Team Dec 04, 2015

You have to use the AP. prefix in front of require... like so:

AP.require('chat', function(chat) {
   chat.appendMessage('Hello!!');
});

BTW, aui.js and jquery aren't required for that to work.

ReferenceError: AP is not defined

<script>
    $.getScript(
        '//bitbucket.org/atlassian/simple-xdm/raw/62355f436bb3966cf4098f41cef544b7dbc4c6bc/dist/iframe.min.js',
        function() {
            $.getScript(
                '//aui-cdn.atlassian.com/aui-adg/5.8.14/js/aui.js',
                function() {
                    AP.require('chat', function(chat) {
                        chat.appendMessage('Hello!!');
                    });
                }
            );
        }
    );
</script>

Seems i missed some js libs to include.

rich Atlassian Team Dec 04, 2015

Why are you loading the script via ajax? Just add it to your <head>.

It's not about html, it's about my firefox plugin. This example - only for clarity

So, where is AP? How i can to include it?

I'm injecting this code direct to room chat.

And after including iframe.min.js i have: Uncaught Error: See almond README: incorrect module build, no module name I googled many times, but could not fix it. It want i define some name

0 votes
oscar Atlassian Team Dec 06, 2015

Hi,

Would you mind explaining what it is you're trying to build? The HipChat Connect framework is meant to be used for addons that run within HipChat, and will not work outside that scope.

So for example, if you're building an extension for Firefox, you won't be able to use HipChat Connect.

Generally, i'm writing firefox plugin which must send some message via chat input. Couldn't do it via javascript button pressing emulation and etc, so, i noticed to api. Ideally i want just set text to input.

rich Atlassian Team Dec 07, 2015

Ah... why don't you just access the chat input element directly and update the value then? The iframe.min.js you're including is specifically for use with HipChat Connect add-ons, not browser add-ons.

rich Atlassian Team Dec 07, 2015

Scratch that... use the `HC.api.appendMessage({text:"TEXT"})` js api to append text to the chat input. Assuming you'll be able to execute you JS directly on the page.

Rich, u are my savior! But where i can read about this api? Considering full task, i need to catch message sending, change message and send. It's real via hacks although...

I have tryed to foreach HC.api, but it haven't any interisting things :( Can i register message-catch event or clear the input?

Found! webpack://./src/js/app/api.js. It haven't input clearer but.. it have sendMessage :smile:

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Hipchat

Hipchat Cloud and Stride have reached End of Life (updated)

All good things come to an end - thanks to all our customers and partners who have been along the Hipchat and Stride journey with us.  As of Feb 15th 2019, Hipchat Cloud and Stride have reached ...

35,206 views 9 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you